package servlet;
import java.io.IOException;
import java.util.Vector;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import common.Property;
import common.SkillManSchema;
import common.SkillManTaxonomy;

public class chooseOntology extends HttpServlet{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public void doGet(HttpServletRequest request,
            HttpServletResponse response)throws ServletException, IOException {

		
		HttpSession session = request.getSession(true);
		
		SkillManSchema r=new SkillManSchema();
		r.setCWD(Property.skillMgmHome);
		r.load();
		
		SkillManTaxonomy tax=r.getTaxonomy();
		Vector<common.MyNode> tree=tax.getTaxonomy();
		
		session.setAttribute("taxonomy", tree);	
		
		String name=request.getParameter("name");
		RequestDispatcher dispatcher=null;
		
		if( name.equals("insert") )
			dispatcher = request.getRequestDispatcher("/insertOntology.jsp");
		else if( name.equals("add") )
			dispatcher = request.getRequestDispatcher("/insertInstance.jsp");
		else if( name.equals("search"))
			dispatcher = request.getRequestDispatcher("/searchInstance.jsp");
			
		dispatcher.forward(request, response);
			

	}

	public void doPost(HttpServletRequest request,
             HttpServletResponse response)
		throws ServletException, IOException {
		doGet(request, response);
	}
	

}
